<template>
  <div class="wrap">
    <div class="count-wrap">
      <div class="count">{{ deviceState.sum || 0 }}</div>
      <div class="count-title">电表总数</div>
    </div>
    <div class="detail-wrap">
      <div class="detail-item">
        <div class="status">
          <img src="../../../assets/images/normal.png" alt="">
          <span>正常</span>
        </div>
        <div class="count-val">{{ deviceState.online || 0 }}</div>
      </div>
      <div class="line"></div>
      <div class="detail-item">
        <div class="status">
          <img src="../../../assets/images/off-line.png" alt="">
          <span>离线</span>
        </div>
        <div class="count-val">{{ deviceState.offline || 0 }}</div>
      </div>
      <div class="line"></div>
      <div class="detail-item">
        <div class="status">
          <img src="../../../assets/images/Arrearage.png" alt="">
          <span>欠费</span>
        </div>
        <div class="count-val">{{ deviceState.arrears || 0 }}</div>
      </div>
      <div class="line"></div>
    </div>
  </div>
</template>
<script>
import { getDeviceState } from '@/api/home/home'
export default {
  name: 'MeterStatus',
  data() {
    return {
      deviceState: {}
    }
  },
  created() {
    this.getData()
  },
  methods: {
    getData() {
      getDeviceState().then(response => {
        this.deviceState = response.data
      })
    }
  }
}
</script>
<style lang="scss" scoped>
.wrap {
  padding: 1.25rem 0 0 1.5rem;
  display: flex;
  .count-wrap {
    .count {
      width: 5.125rem;
      height: 5.125rem;
      background-image: url("../../../assets/images/meter-quantity.png");
      background-size: 100% 100%;
      font-family: Microsoft YaHei, Microsoft YaHei;
      font-weight: bold;
      font-size: 1.25rem;
      color: #73FCFD;
      text-align: center;
      line-height: 5.125rem;
    }
    .count-title {
      font-family: Microsoft YaHei, Microsoft YaHei;
      font-weight: 400;
      font-size: 0.875rem;
      color: #E5EAF3;
      text-align: center;
      margin-top: 1.25rem;
    }
  }
  .detail-item {
    width: 13.375rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: Microsoft YaHei, Microsoft YaHei;
    margin: 0 0 0 2.75rem;
    .status{
      font-weight: 400;
      font-size: 0.875rem;
      color: #FFFFFF;
      display: flex;
      align-items: center;
      img {
        width: 1rem;
        height: 1.125rem;
        margin-right: 0.625rem;
      }
    }
    .count-val {
      font-weight: bold;
      font-size: 1rem;
      color: #73FCFD;
    }
  }
  .line {
    width: 13.375rem;
    height: 1px;
    background: radial-gradient( rgba(64,144,176,0.6) 0%, rgba(64,144,176,0.1) 100%);
    margin: 0.625rem 0 1rem 2.75rem;
  }
}
</style>